package com.hy.erp.inventory.service;

import javax.ejb.Stateless ;

import org.jboss.seam.Component ;
import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.contexts.Contexts ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IConcessionReceivebillDao;
import com.hy.erp.inventory.pojo.ConcessionReceivebill;
import com.hy.erp.inventory.pojo.interfaces.IConcessionReceivebill;
import com.hy.erp.inventory.service.PurchasingRejectionOutBoundServicePack.interfaces.IPurchasingRejectionAssistInfomationService;
import com.hy.erp.inventory.service.interfaces.IConcessionReceivebillService;
import com.hy.erp.inventory.service.interfaces.warehousing.IDisqualificationDealStyleAssistService;

/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-25；时间：下午04:21:16</li>
 * <li>类型名称：ConcessionReceivebillService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Name("concessionReceivebillService")
@Scope(ScopeType.SESSION)
@Stateless
public class ConcessionReceivebillService extends AbstractBusinessService < IConcessionReceivebill > implements IConcessionReceivebillService
{

	@ Override
	public boolean addConcessionReceivebill (
												ConcessionReceivebill concessionReceivebill )
	{




		if ( null == concessionReceivebill)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;

			String[] ids=( String [ ] ) Contexts.getSessionContext ( ).get ( "Ids" );
			IDisqualificationDealStyleAssistService service= ( IDisqualificationDealStyleAssistService ) Component.getInstance ( "disqualificationDealStyleAssistService" );
			concessionReceivebill.setDisqualificationDealStyleAssist ( service.getDisqualificationDealStyleAssistById ( ids ) );
			

			IConcessionReceivebillDao concessionReceivebillDao =
			                       ( IConcessionReceivebillDao ) this
			                                          .getDao ( IConcessionReceivebill.class ) ;
			
		
			return concessionReceivebillDao
			                .persist ( concessionReceivebill ) ;
		}
		
	
	
	
	
	}

	@ Override
	public boolean modifyConcessionReceivebill (
													ConcessionReceivebill concessionReceivebill )
	{






		if ( ( null == concessionReceivebill )
		     || ( null == concessionReceivebill
		                                .getIdentifier ( ) )
		     || ( concessionReceivebill
		                        .getIdentifier ( )
		                        .trim ( )
		                        .length ( ) == 0 ) )
		{
			return true ;
		}
		else
		{


			IConcessionReceivebillDao concessionReceivebillDao =
                ( IConcessionReceivebillDao ) this
                                   .getDao ( IConcessionReceivebill.class ) ;
				
			if ( null == concessionReceivebill )
			{
				throw new ArchitectureFoundationException  (
				                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			
			
			return ( concessionReceivebillDao
			                  .merge ( concessionReceivebill ) != null ) ;
		}
	
	
	
	
	
	
	}

	@ Override
	public Integer removeConcessionReceivebill (
													String [ ] concessionReceivebillIds )
	{




		if ( ( null == concessionReceivebillIds )
			     || ( concessionReceivebillIds.length == 0 ) )
		{
			return new Integer (
			                     0 ) ;
		}
		else
		{System.out
					.println (concessionReceivebillIds.length+"HHHHHHHHHHHHHH") ;
			
		IConcessionReceivebillDao concessionReceivebillDao =
            ( IConcessionReceivebillDao ) this
                               .getDao ( IConcessionReceivebill.class ) ;
			return concessionReceivebillDao
			                .remove ( concessionReceivebillIds ) ;
		}
		
	
	
	
	
	}

}
